import { Body, Controller, Get, Post, Query, Redirect, Req, Res } from '@nestjs/common';
import { Request, Response } from 'express'
import { PayNoticeService } from './pay_notice.service';

@Controller('payNotice')
export class PayNoticeController {
    constructor(
        private readonly payNotice: PayNoticeService
    ) { }

    @Post()
    async wechat(@Body() body: any, @Req() request: Request, @Res() response: Response) {
        response.status(200);
        return await this.payNotice.handlingNotifications(body, request, response);
    }
    @Post('/ali')
    async ali(@Body() body: any) {
        console.log(body);
        return await this.payNotice.handlingNotificationsToAli(body);
    }
    @Get()
    @Redirect('http://localhost:3001/user/order', 302)
    async aliReturn(@Query() query, @Res() res: Response) {
        console.log(query);
        return await this.payNotice.handlingAliReturnUrl(query, res);
    }

}